<?php

namespace App\Http\Controllers\Admin;

use App\Models\Fangowner;
use App\Models\Notice;
use App\Models\Renting;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class NoticeController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $url=route('admin.notice.create');
        return "<a href='$url'>添加预约</a>";
    }
    //添加预约
    public function create()
    {
        //房东
        $fData=json_encode(Fangowner::get()->toArray(),JSON_UNESCAPED_UNICODE);
        //租客
        $rData=json_encode(Renting::get()->toArray(),JSON_UNESCAPED_UNICODE);
        return view('admin.notice.create',compact('fData','rData'));
    }

   //接收表单数据入库
    public function store(Request $request)
    {
        //得到数据
        $data=$request->except('_token');
        Notice::create($data);
        return ['code'=>0,'msg'=>'成功','url'=>route('admin.notice.index')];
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Models\Notice  $notice
     * @return \Illuminate\Http\Response
     */
    public function show(Notice $notice)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Models\Notice  $notice
     * @return \Illuminate\Http\Response
     */
    public function edit(Notice $notice)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Notice  $notice
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Notice $notice)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Models\Notice  $notice
     * @return \Illuminate\Http\Response
     */
    public function destroy(Notice $notice)
    {
        //
    }
}
